package xyz.whiteblue.beetl;

import org.beetl.core.Configuration;
import org.beetl.core.GroupTemplate;
import org.beetl.core.resource.WebAppResourceLoader;
import xyz.whiteblue.core.Config;
import xyz.whiteblue.core.PathUtil;
import xyz.whiteblue.render.Render;

import java.io.IOException;

/**
 * Created by WhiteBlue on 15/1/21.
 */
public class BeetlRenderFactory {

    public static GroupTemplate groupTemplate = null;

    public static void init() throws IOException {
        Configuration cfg = Configuration.defaultConfiguration();

        WebAppResourceLoader resourceLoader = new WebAppResourceLoader();

        resourceLoader.setRoot(PathUtil.getRootPath() + Config.getTemplatePath());

        groupTemplate = new GroupTemplate(resourceLoader, cfg);

    }

    public static Render getRender(String view) {
        return new BeetlRender(groupTemplate, view);
    }


}